local 系统类_时辰 = class()
local floor = math.floor
local ARGB = ARGB
local require = require
local 矩阵 = require("gge包围盒")(0,0,115,95)
local tp
local zt
local format = string.format
local keytq = 引擎.按键弹起

function 系统类_时辰:初始化(根)
	local 资源 = 根.资源
	local 按钮 = 根._按钮
  --self.时辰 = 资源:载入('wzife.wdf',"网易WDF动画",0xC9E2F072)
	self.序列=1
	self.屏蔽 = false
	self.地图 = nil
	self.偏移 = nil
	self.计时 = 0
	self.计次 = 150
	self.隐藏图标=true
	self.昼夜=1
	self.天气=0
	-- self.偏移坐标 = 0
	tp = 根
	zt = require("gge文字类").创建(nil,15,false,true,false)
	local g = {0xB9FD3C98,0xFE026DC3,0xCDB4C444,0xDFE4105D,0xA66B9C4,0x5A94EB4C,0xD2A6E5EC,0xEEADB7F5,0x399E1F40,0x6FFBDFD8,0xDEBA9F52,0x49D3DE80}
	self.时辰={}
	for n=1,12 do
	  self.时辰[n]=资源:载入('common/wzife.wdf',"网易WDF动画",g[n])
	end
	self.梦幻指引 = 按钮.创建(资源:载入('wzife.wd2',"网易WDF动画",0xF102F42D),0,0,4)
	self.帮战报 = 按钮.创建(资源:载入('wzife.wdf',"网易WDF动画",1714563470),0,0,1,true)
   	self.导航 = 按钮.创建(资源:载入('common/wzife.wdf',"网易WDF动画",0x30712485),0,0,4) --导航
	self.世界 = 按钮.创建(资源:载入('common/wzife.wdf',"网易WDF动画",0xCA5242C2),0,0,4)
	self.日历 = 按钮.创建(资源:载入('common/wzife.wdf',"网易WDF动画",0xAD514E92),0,0,4)
	self.查询 = 按钮.创建(资源:载入('common/wzife.wdf',"网易WDF动画",0x6ECBCED7),0,0,4) --放大镜
	self.白昼 = 资源:载入('common/wzife.wdf',"网易WDF动画",0xAA23B98F)
	self.黑昼 = 资源:载入('common/wzife.wdf',"网易WDF动画",0x82DB3814)
	self.起风 =资源:载入('common/wzife.wdf',"网易WDF动画",0x50578CFA)
	self.下雨 =资源:载入('common/wzife.wdf',"网易WDF动画",0xB21A8CFA)
	self.下雪 =资源:载入('common/wzife.wdf',"网易WDF动画",0xB2B98CFA)
	self.下雨特效 = 资源:载入('mapani.wdf',"网易WDF动画",0x71C42D59)
	self.打雷特效 = 资源:载入('mapani.wdf',"网易WDF动画",1800426471)
	self.起风特效 = 资源:载入('mapani.wdf',"网易WDF动画",0xC8697349)
	self.风吹云彩 = 资源:载入('mapani.wdf',"网易WDF动画",0xF12D26BF)
	self.下雪特效 = 资源:载入('addon.wdf',"网易WDF动画",0x98300C2D)
	self:qiehuan(全局界面风格)

	self.图标1 = 按钮.创建(资源:载入('登陆资源.wdf',"网易WDF动画",0x0D000003),0,0,1,true)--攻略
	self.图标2 = 按钮.创建(资源:载入('登陆资源.wdf',"网易WDF动画",0x0D000013),0,0,1,true)--组队
	self.图标3 = 按钮.创建(资源:载入('登陆资源.wdf',"网易WDF动画",0x0D000011),0,0,1,true)--背包
	self.图标4 = 按钮.创建(资源:载入('登陆资源.wdf',"网易WDF动画",0x0D000006),0,0,1,true)--功能
	self.图标5 = 按钮.创建(根.资源:载入('登陆资源.wdf',"网易WDF动画",0xff205592),0,0,1,true)--宝宝进阶
	self.图标6 = 按钮.创建(资源:载入('嘎嘎.wdf',"网易WDF动画",0x10000006),0,0,1,true)--VIP特权按键
	self.图标7 = 按钮.创建(资源:载入('嘎嘎.wdf',"网易WDF动画",0x10000005),0,0,1,true)--内充
	self.图标8 = 按钮.创建(根.资源:载入('common/wzife.wdf',"网易WDF动画",0xDF5D76D6),0,0,1,true)--称号
	self.隐藏 = 按钮.创建(资源:载入('嘎嘎.wdf',"网易WDF动画",0x10000007),0,0,1,true)--隐藏按钮
end
function 系统类_时辰:qiehuan(风格)
	local 按钮 = tp._按钮
	-- local 自适应 = tp._自适应
	local 资源 = tp.资源
	if  风格=="国韵" then
		self.背景 = 资源:载入('common/uigy.wdf',"网易WDF动画",4138033197)
		self.收缩 = 按钮.创建(资源:载入('common/uigy.wdf',"网易WDF动画",1817603562),0,0,4)
	elseif  风格=="水晶" then
		self.背景 = 资源:载入('common/uisj.wdf',"网易WDF动画",4138033197)
		self.收缩 = 按钮.创建(资源:载入('common/uisj.wdf',"网易WDF动画",1817603562),0,0,4)
	else
		self.背景 = 资源:载入('common/wzife.wdf',"网易WDF动画",0xF6A5602D)
		self.收缩 = 按钮.创建(资源:载入('wzife.wdf',"网易WDF动画",0x6EDD4D71),0,0,4)
	end
end
function 系统类_时辰:刷新()
	self.地图 = 取地图名称(tp.当前地图)
	self.偏移 = 60 - #self.地图*3.72
end
function 系统类_时辰:显示(dt,x,y)
	if 矩阵:检查点(x,y) then
		tp.选中UI = true
	end
	self.下雪特效:更新(dt)
	self.起风特效:更新(dt)
	self.风吹云彩:更新(dt)
	self.下雨特效:更新(dt)
	self.打雷特效:更新(dt)
	self.背景:显示(0,0 )
	self.收缩:更新(x,y)
	self.收缩:显示(10,49)
	self.世界:更新(x,y)
	self.世界:显示(30,42 )
	self.日历:更新(x,y)
	self.日历:显示(120,42 )
	self.查询:更新(x,y)
	self.查询:显示(65,42 )
	self.导航:更新(x,y)
	self.导航:显示(95,42)
	昼夜=self.昼夜
	天气=self.天气
	if 昼夜 == 1 then
		self.黑昼:显示(15,6 )
	else
		self.白昼:显示(15,6 )
	end
	if not 低配模式 then
		if 天气==1 then
			self.起风:显示(13,26 )
			self.起风特效:显示(700,500)
			self.起风特效:显示(600,400)
			self.起风特效:显示(500,300)
			self.起风特效:显示(400,200)
			self.起风特效:显示(300,100)
			self.起风特效:显示(x,y)
			self.风吹云彩:显示(400,0)
			self.风吹云彩:显示(440,50)
			self.风吹云彩:显示(480,75)
			self.风吹云彩:显示(520,100)
			self.风吹云彩:显示(560,130)
		elseif 天气==2 then
			self.下雨:显示(13,26 )
			local x=math.random(1,500)
			local y=math.random(1,500)
			self.下雨特效:显示(50,200 )
			self.下雨特效:显示(400,200 )
			--self.打雷特效:显示(x,y )
		elseif 天气==3 then
			self.下雪:显示(13,26 )
			self.下雪特效:显示(200,100 )
			self.下雪特效:显示(200,300 )
			self.下雪特效:显示(200,500 )
			self.下雪特效:显示(500,100 )
			self.下雪特效:显示(500,300 )
			self.下雪特效:显示(500,500 )
			self.下雪特效:显示(800,100 )
			self.下雪特效:显示(800,300 )
			self.下雪特效:显示(800,500 )
		end
	end--
	self.时辰[self.序列]:显示(39,7.5)
   	if not tp.战斗中 then
   	self.隐藏:更新(x,y)
   	self.隐藏:显示(140,30)
    	if self.隐藏图标 then
			self.图标1:更新(x,y)
			self.图标2:更新(x,y)
			self.图标3:更新(x,y)
			self.图标4:更新(x,y)
			self.图标5:更新(x,y)
			self.图标1:显示(170,9)--背包
			self.图标2:显示(170+55,13) -- 组队
			self.图标3:显示(170+55+50,16) -- 攻略
			self.图标4:显示(170+55+50+50,9) -- 功能
			self.图标5:显示(170+55+50+50+50,9) -- 挂机
	    	end
	    	if self.图标1:是否选中(x,y)  then
			tp.提示:自定义(170,y+9,"超级背包")
			 elseif self.图标2:是否选中(x,y)  then
			 tp.提示:自定义(170+55,13,"一健组队")
			 elseif self.图标3:是否选中(x,y)  then
			 tp.提示:自定义(170+55+50,16,"游戏攻略")
			 elseif self.图标4:是否选中(x,y)  then
			 tp.提示:自定义(170+55+50+50,9,"VIP功能")
			 elseif self.图标5:是否选中(x,y)  then
			 tp.提示:自定义(170+55+50+50+50,9,"挂机功能")
			end
	     	if self.图标1:事件判断() then
	     		if tp.窗口.共享道具.可视 then
			    tp.窗口.共享道具:打开()
				else
				JGESDK:发送(3741.1,{内容="杂货"})
				end
			elseif self.图标2:事件判断() then
			JGESDK:发送(4017)
     		elseif self.图标3:事件判断() then
     			tp.窗口.游戏攻略:打开()
     		elseif self.图标4:事件判断() then
     			  tp.窗口.功能界面:打开()
     	elseif self.图标5:事件判断() then
     		JGESDK:发送(550) --挂机
     		elseif self.隐藏:事件判断() then
        	self.隐藏图标= not self.隐藏图标
      	end
   end

	if self.偏移~=nil then
		zt:置颜色(黄色)
		zt:显示(75,5.5,os.date("%X", os.time()))
		local xy = "["..floor(tp.角色坐标.x/20)..","..floor(tp.角色坐标.y/20).."]"
		zt:置颜色(白色)
		zt:显示(self.偏移-12,23.5 ,self.地图..xy)
	end
	if not tp.战斗中 then
		if 帮战开关  then
		    self.帮战报:更新(x,y)
			self.帮战报:显示(5,114)
			if self.帮战报:事件判断() then
				if tp.窗口.帮战建设.可视 == false then
				    JGESDK:发送(6551)
				else
					tp.窗口.帮战建设:打开()
				end
			end
		end

		if self.世界:是否选中(x,y) and tp.选中窗口 == 0 then
			tp.提示:自定义(x-42,y+27,"快捷键:ALT+M")
		elseif self.查询:是否选中(x,y) and tp.选中窗口 == 0 then
			tp.提示:自定义(x-42,y+27,"快捷键:Tab")
		elseif self.图标1:是否选中(x,y) and tp.选中窗口 == 0 then
		elseif self.图标2:是否选中(x,y) and tp.选中窗口 == 0 then
			-- tp.提示:自定义(x-42,y+27,"抽奖")
		elseif self.图标3:是否选中(x,y) and tp.选中窗口 == 0 then
			-- tp.提示:自定义(x-42,y+27,"抽奖")
		-- elseif self.图标4:是否选中(x,y) and tp.选中窗口 == 0 then
		-- 	tp.提示:自定义(x-42,y+27,"购买自动抓鬼卡")
		elseif self.图标5:是否选中(x,y) and tp.选中窗口 == 0 then
		elseif self.图标6:是否选中(x,y) and tp.选中窗口 == 0 then
		elseif self.图标7:是否选中(x,y) and tp.选中窗口 == 0 then
			-- tp.提示:自定义(x-42,y+27,"充值")
	   	elseif self.导航:是否选中(x,y) and tp.选中窗口 == 0 then
            	tp.提示:自定义(x-42,y+27,"排行榜")
      	elseif self.日历:是否选中(x,y) and tp.选中窗口 == 0 then
            	tp.提示:自定义(x-42,y+27,"玩法指引")
		end
		if self.世界:事件判断(x,y) and tp.选中窗口 == 0  then
		 	tp.窗口.世界大地图:打开()
	 	elseif (self.查询:事件判断() or keytq(KEY.TAB))  and not tp.消息栏焦点 then
	 		tp.窗口.小地图:打开(tp.当前地图)
 		elseif self.日历:事件判断(x,y)  and tp.选中窗口 == 0 then
	 		JGESDK:发送(66)
		end

		  if self.导航:事件判断() and not tp.战斗中  and tp.选中窗口 == 0 then
		if tp.窗口.排行榜.可视==false then
			JGESDK:发送(39)
		else
			tp.窗口.排行榜:打开()
		end
		end
	end
end

function 系统类_时辰:检查点(x,y)
	return 矩阵:检查点(x,y)
end

return 系统类_时辰